//
//  CCInternalMacros.h
//  CCFoundation
//
//  Created by zjh on 2021/9/27.
//

#import <Foundation/Foundation.h>

#ifndef CC_LOCK
#define CC_LOCK(lock) dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER);
#endif

#ifndef CC_UNLOCK
#define CC_UNLOCK(lock) dispatch_semaphore_signal(lock);
#endif

/******************************   主线程   ******************************/
#ifndef dispatch_main_async_safe
#define dispatch_main_async_safe(block)\
    if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) {\
        block();\
    } else {\
        dispatch_async(dispatch_get_main_queue(), block);\
    }
#endif


#define CCCode_Async_Begin         \
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{\

#define CCCode_Async_End \
    });

/******************************   Font   ******************************/
#define Font(f)         [UIFont systemFontOfSize:f]
#define FontM(f)        [UIFont fontWithName:@"PingFangSC-Medium" size: f]
#define FontR(f)        [UIFont fontWithName:@"PingFangSC-Regular" size: f]
#define FontS(f)        [UIFont fontWithName:@"PingFangSC-Semibold" size: f]
